package com.gxa.saas.portal.service.impl;

import com.gxa.saas.core.vo.GoodsDetailsVo;
import com.gxa.saas.portal.mapper.GoodsDetailsMapper;
import com.gxa.saas.portal.service.GoodsDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Auther: pengxtao
 * @Date: 2022/7/22下午4:52
 */
@Service
public class GoodsDetailsServiceImpl implements GoodsDetailsService {

    @Autowired
    private GoodsDetailsMapper goodsDetailsMapper;


    @Override
    public Map selectGoodsDetail(String prId) {
        try {
            GoodsDetailsVo goodsDetailsVo = goodsDetailsMapper.selectDetailsGoods(prId);
            String firstName = this.goodsDetailsMapper.selectDetailfirstCaly(prId);
            goodsDetailsVo.setFirstName(firstName);
            List<String> color = this.goodsDetailsMapper.selectDetailColor(prId);
            goodsDetailsVo.setColorName(color);
            List<String> secondeName = this.goodsDetailsMapper.selectDetailsecondeCaly(prId);
            goodsDetailsVo.setSeName(secondeName);
            List<String> speName = this.goodsDetailsMapper.selectDetailsSpeName(prId);
            goodsDetailsVo.setSpeName(speName);
            List<String> pictureList = this.goodsDetailsMapper.selectDetailsPicture(prId);
            goodsDetailsVo.setPicture(pictureList);
            List<GoodsDetailsVo> GoodsDetailsVoList = new ArrayList();
            GoodsDetailsVoList.add(goodsDetailsVo);
            Map map = new HashMap();
            map.put("code",200);
            map.put("data",GoodsDetailsVoList);
            return map;
        }catch (Exception e){
            e.printStackTrace();
            Map map = new HashMap();
            map.put("code",500);
            map.put("message","系统异常！");
            return map;
        }
    }
}
